/*
 * @Author: Shane
 * @Date: 2022-06-30 15:59:54
 * @LastEditTime: 2022-06-30 15:59:56
 * @LastEditors: Shane
 * @Description: 
 * @FilePath: /app-framework/common_widgets/lib/loading/ball.dart
 */

import 'package:flutter/material.dart';

import 'ball_style.dart';

class Ball extends StatelessWidget {
  ///
  /// 球样式
  ///
  final BallStyle style;

  const Ball({
    Key? key,
    this.style = kDefaultBallStyle,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    BallStyle _ballStyle = kDefaultBallStyle.copyWith(
        size: style.size,
        color: style.color,
        ballType: style.ballType,
        borderWidth: style.borderWidth,
        borderColor: style.borderColor);

    return SizedBox(
      width: _ballStyle.size,
      height: _ballStyle.size,
      child: DecoratedBox(
        decoration: BoxDecoration(
            shape: BoxShape.circle,
            color:
                _ballStyle.ballType == BallType.solid ? _ballStyle.color : null,
            border: Border.all(
                color: _ballStyle.borderColor, width: _ballStyle.borderWidth)),
      ),
    );
  }
}
